import java.util.Arrays;
import java.util.Collections;

public class L26 {


    public static void main(String[] args) {
//        int[] nums = {1, 1, 2};
        int[] nums = {0, 0, 1, 1, 1, 2, 2, 3, 3, 4};
        int i = new Solution().removeDuplicates(nums);
        System.out.println(i);
        for (int num : nums) {
            System.out.println(num);
        }

    }


    static class Solution {
        public int removeDuplicates(int[] nums) {
            if (nums.length < 2) {
                return nums.length;
            }

            int i = 1;
            int val = nums[0];

            for (int k = 1; k < nums.length; k++) {
                if (val != nums[k]) {
                    nums[i] = nums[k];
                    val = nums[k];
                    i++;
                }

            }

            return i;
        }
    }
}